/*
 * $Id: SiteForm.java 112 2009-07-01 11:33:10Z donbeave $
 */

package labour.manager.client.widget.form;

import labour.concept.engine.client.data.Site;

import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.LabelField;
import com.extjs.gxt.ui.client.widget.form.TextField;

public class SiteForm extends FormPanel {

  private LabelField idField;
  private TextField<String> nameField;

  public SiteForm() {
    setHeading("Site");

    setFrame(true);

    idField = new LabelField();
    idField.setFieldLabel("ID");
    add(idField);

    nameField = new TextField<String>();
    nameField.setFieldLabel("Name");
    add(nameField);
  }

  public SiteForm(Site model) {
    this();

    setItem(model);
  }

  public LabelField getIdField() {
    return idField;
  }

  public TextField<String> getNameField() {
    return nameField;
  }

  public Site getItem() {
    return getData("MODEL");
  }

  public void setItem(Site item) {
    setData("MODEL", item);

    getIdField().setValue(item.getModel().getId());
    getNameField().setValue(item.getModel().getName());
  }

}
